﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using System.Data.SqlClient;
using System.Configuration;
using Dapper;
using System.Data;

namespace DAL
{
    public class MFGDAL
    {
        public static readonly string SqlConnString = ConfigurationManager.ConnectionStrings["ELCO_ConnectionString"].ConnectionString;

        public static List<CustomerNameChejianimg> getCustomInfoByID(string ID)
        {
            using (var conn = new SqlConnection(SqlConnString))
            {

                string str = "select ID, CustomName,CustomChejian,CustomImg from CustomInfo where ID='" + ID + "' ";
                return conn.Query<CustomerNameChejianimg>(str).ToList();
            }
        }

        public static List<EquKaoHaoList> getEquNoListByID(string ID)
        {
            using (var conn = new SqlConnection(SqlConnString))
            {

                string str = "select EquNo, EquType,FangShaKind,'' as state from CustomerEquInfo where CustomerID='" + ID + "' ";
                List<EquKaoHaoList> list = conn.Query<EquKaoHaoList>(str).ToList();
                foreach(EquKaoHaoList equ in list){
                    equ.fangshachangdu = "421";
                    equ.xiaolv = "85%";
                    equ.chesu = "56";
                    equ.state = "1";
                }
                return list;
            }
        }

        public static List<ShengchanCusha> shengchancusha(string EquNo)
        {
            using (var conn = new SqlConnection(SqlConnString))
            {
                List<ShengchanCusha> list = new List<ShengchanCusha>();
                ShengchanCusha info = new ShengchanCusha();
                info.EquNo = EquNo;
                info.ChangDu = "20m";
                info.XiaoLv = "80%";
                info.ZaobanChanliang = "50";
                info.ZaobanXiaolv = "70%";
                info.ZhongbanChanliang = "60";
                info.ZhongbanXiaolv = "80%";
                info.WanbanChanliang = "80";
                info.WanbanXiaolv = "90%";
                list.Add(info);
                return list;
            }
        }

        public static List<ShengchanCushaAlarm> shengchancushadangqianfangsha(string EquNo)
        {
            using (var conn = new SqlConnection(SqlConnString))
            {
                List<ShengchanCushaAlarm> list = new List<ShengchanCushaAlarm>();
                ShengchanCushaAlarm info = new ShengchanCushaAlarm();
                info.EquNo = EquNo;
                info.AlarmTime = "2018-07-19 13:24:26";
                //info.AlarmType = "报警类型1";
                info.AlarmName = "报警信息1";
                list.Add(info);
                return list;
            }
        }

        public static List<guidaoshengchannum> getguidaoshengchanByID(string ID)
        {
            using (var conn = new SqlConnection(SqlConnString))
            {
                List<guidaoshengchannum> list = new List<guidaoshengchannum>();
                guidaoshengchannum info = new guidaoshengchannum();
                info.EquNo = "JB2222";
                info.GuiDaoNo = "1";
                info.FangShaKind = "品种1";
                info.rukumanshanum = "100";
                info.chukumanshanum = "88";
                info.kucunmanshanum = "210";
                info.kucunkongguannum = "50";
                list.Add(info);
                list.Add(info);
                list.Add(info);
                list.Add(info);
                list.Add(info);
                list.Add(info);
                return list;
            }
        }
    }
}
